package com.rgp.apiboss.service.impl;

import com.rgp.apiboss.feign.ServiceDriverUserClient;
import com.rgp.apiboss.service.DriverUserService;
import com.rgp.internalcommon.common.CommonStatusEnum;
import com.rgp.internalcommon.dto.DriverUserDto;
import com.rgp.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-16 18:05
 */
@Service
public class DriverUserServiceImpl implements DriverUserService {

    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient;

    @Override
    public ResponseResult addDriverUser(DriverUserDto driverUserDto) {
        ResponseResult result = serviceDriverUserClient.addDriver(driverUserDto);
        if (result.getCode().equals(CommonStatusEnum.SUCCESS.getCode())){
            return result;
        }else {
            return ResponseResult.fail(CommonStatusEnum.DRIVER_USER_INSERT_ERROR);
        }
    }

    @Override
    public ResponseResult updateDriverUser(DriverUserDto driverUserDto) {
        ResponseResult result = serviceDriverUserClient.updateDriver(driverUserDto);
        if (result.getCode().equals(CommonStatusEnum.SUCCESS.getCode())){
            return result;
        }else {
            return ResponseResult.fail(CommonStatusEnum.DRIVER_USER_UPDATE_ERROR);
        }
    }
}